import {saveMetadata, getMetadataByNamespace, all, detail, metadatas} from '../../api/metadata'

const actions = {

    save({commit}, params) {
        return new Promise((resolve, reject) => {
            saveMetadata(params).then(response => {
                const { data } = response
                commit("","")
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    },

    namespace({commit}, params){
        return new Promise((resolve, reject) => {
            getMetadataByNamespace(params).then(response => {
                const { data } = response
                commit("","")
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    },

    all(){
        return new Promise((resolve, reject) => {
            all().then(response => {
                const { data } = response
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    },

    detail({commit}, params){
        return new Promise((resolve, reject) => {
            detail(params).then(response => {
                const { data } = response
                commit("","")
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    },

    metadatas({commit}, params){
        return new Promise((resolve, reject) => {
            metadatas(params).then(response => {
                const { data } = response
                commit("","")
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    }

}

export default {
    namespaced: true,
    actions
}